package com.zgis.monitor.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 属性配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "monitor")
public class MonitorConfig
{
    // 全局检查间隔(秒)
    private int                checkRate   = 30;
    // 全局是否自动重启
    private boolean            autoRestart = true;
    // 所有服务器配置
    private List<ServerConfig> servers;

    @Data
    public static class ServerConfig
    {
        private String              ip;
        private int                 sshPort = 22;
        private String              username;
        private String              password;
        // 该服务器上的所有服务
        private List<ServiceConfig> services;
    }

    @Data
    public static class ServiceConfig
    {
        private String  id;
        private String  name;
        // 服务类型:JAR、DOCKER
        private String  type;
        // 端口
        private int     port;
        // JAR相关配置
        private String  jarPath;
        // compose文件路径
        private String  composePath;
        // 启动命令
        private String  startCommand;
        // Docker相关配置
        private String  containerName;

        private String mailRecipients; // 收件人邮箱列表
        // 附件人
        private String  username;
        // 单独配置检查间隔
        private Integer checkRate;
        // 单独配置是否自动重启
        private Boolean autoRestart;
    }
}
    